package com.ihg.hiex.admin.entity.search;

import java.util.Map;
import com.demo2do.core.persistence.support.QueryBuilder;
import com.demo2do.core.persistence.support.QueryFilter;
import com.demo2do.core.persistence.support.QueryOrder;

/**
 * @author ZEAL
 *
 */
public class SupervisorSearch implements QueryBuilder {

    /**
     * Email
     */
    private String name;

    private String email;

    private String telephone;

    private QueryFilter queryFilter;

    private QueryOrder queryOrder;

    public SupervisorSearch() {

    }

    /*
     * (non-Javadoc)
     * 
     * @see com.demo2do.core.persistence.support.QueryBuilder#getPreparedFilter(
     * boolean)
     */
    public QueryFilter getPreparedFilter(boolean refresh) {
        if (queryFilter == null || refresh) {
            queryFilter = new QueryFilter();

            queryFilter.addLike("name", name)
                       .addLike("email", email)
                       .addLike("telephone", telephone);
        }
        return queryFilter;
    }

    /*
     * (non-Javadoc)
     * 
     * @see com.demo2do.core.persistence.support.QueryBuilder#getOrder()
     */
    public QueryOrder getOrder() {

        queryOrder = new QueryOrder();

        return queryOrder;
    }

    /*
     * (non-Javadoc)
     * 
     * @see
     * com.demo2do.core.persistence.support.QueryBuilder#buildSentenceTemplate()
     */
    public String buildSentenceTemplate() {

        String template = "FROM Supervisor WHERE disabled = false " + getPreparedFilter(false).clauseSentence()
                + getOrder().sentence();

        return template;
    }

    /*
     * (non-Javadoc)
     * 
     * @see com.demo2do.core.persistence.support.QueryBuilder#buildParameters()
     */
    public Map<String, Object> buildParameters() {

        return getPreparedFilter(false).parameters();
    }

    /**
     * @return the name
     */
    public String getName() {
        return name;
    }

    /**
     * @return the email
     */
    public String getEmail() {
        return email;
    }

    /**
     * @return the telephone
     */
    public String getTelephone() {
        return telephone;
    }

    /**
     * @param name
     *            the name to set
     */
    public void setName(String name) {
        this.name = name;
    }

    /**
     * @param email the email to set
     */
    public void setEmail(String email) {
        this.email = email;
    }

    /**
     * @param telephone the telephone to set
     */
    public void setTelephone(String telephone) {
        this.telephone = telephone;
    }
}
